/**
 * 
 */
package br.skytef.stmanager.daos;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import br.skytef.stmanager.utils.Pool;

/**
 * @author Ivam Henrique Marques dos Santos
 *         email: ivam.santos@skytef.com.br
 *         skype: ivam.santos.skytef
 *         telefone: +55 11 96214-7543
 */
public class UtcDAO {
	
	private static String erro;
	public static String getErro() {return erro;}
	
	private static Connection conexao = null;
	
	public boolean inserirUTC(long idTarefa, int idCli, int idUser){
		try {
			conexao = Pool.getConnection();
			
			String query ="INSERT INTO utc(tarefa_id, cliente_idCliente, usuario_id)"
					+ "VALUES(?,?,?);";
			PreparedStatement preparedStmt = conexao.prepareStatement(query);
			preparedStmt.setLong     		(1, idTarefa);
			preparedStmt.setInt     		(2, idCli);
			preparedStmt.setInt     		(3, idUser);
			preparedStmt.execute();			
			conexao.close();
			return true;

		} catch (SQLException e) {
			System.out.println("SQL erro: "+ e);
			erro=e.toString();
			return false;
		}catch (ClassCastException e) {
			System.out.println("Classe erro: "+ e);
			erro=e.toString();
			return false;
		} catch (Exception e) {
			System.out.println("Geral erro: "+ e);
			erro=e.toString();
			return false;
		}
	}
	
	
}
